package com.car.account.controller;


import com.car.account.dto.platformResource.PlatformResourceDto;
import com.car.account.entity.PlatformResource;
import com.car.account.service.PlatformResourceService;
import com.car.commons.core.model.Result;
import com.car.commons.core.util.JwtUtil;
import com.car.commons.web.util.WebUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 董旭
 * @since 2024-08-28
 */
@RestController
@RequestMapping("/platformResource")
public class PlatformResourceController {
    @Resource
    private PlatformResourceService platformResourceService;
    @GetMapping("/load.pt")
    public Result load() throws Exception {
        String token = WebUtil.getToken();
        Integer adminId = JwtUtil.getAdminId(token);
        ArrayList<PlatformResourceDto> platformResourceDtos= platformResourceService.load(adminId);
        return Result.getResult().setMsg("加载权限成功").setData(platformResourceDtos);
    }


    @GetMapping("/ids.pt")
    public Result findAllIds() {
        return Result.getResult().setData(platformResourceService.list());
    }
}

